Skip to content

Database lab3#3

Closed
mattknatt wants to merge 7 commits into
mainfrom
database_lab3
Closed

Database lab3#3
mattknatt wants to merge 7 commits into
mainfrom
database_lab3

Conversation

@mattknatt

@mattknatt mattknatt commented Dec 5, 2025

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added user authentication and login system
    • Added account management features (registration, password updates, account deletion)
    • Added moon mission search and filtering capabilities
    • New interactive menu-driven interface for all user operations
  • Infrastructure

    • Integrated MySQL database for data persistence
    • Added logging support
  • Documentation

    • Updated README with review assignment information

✏️ Tip: You can customize this high-level summary in your review settings.

github-classroom Bot and others added 7 commits December 1, 2025 06:50
…and Moon Missions with implementation classes. First 4 tests are green.
…ion through. Added SimpleDriverManagerDataSource to inject datasource into Repositories. All tests pass but throws exception related to Scanner when running CliAppIT.
…s pass without the previous exception caused by scanner problems.
@coderabbitai

coderabbitai Bot commented Dec 5, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a database-driven architecture with repository pattern, DataSource abstraction layer, Docker MySQL setup, SLF4J logging dependencies, and an interactive CLI login system for account management and moon mission querying.

Changes

Cohort / File(s) Change Summary
Configuration & Dependencies
README.md, docker-compose.yml, pom.xml
Added README review badge; defined MySQL 9.5.0 service with environment variables, port mapping, and named volume; added SLF4J API and no-op logger dependencies (version 2.0.17).
Domain Models
src/main/java/com/example/Account.java, src/main/java/com/example/MoonMission.java
Created Account class with user_id, name, password, first_name, last_name, ssn fields; created MoonMission class with mission_id, spacecraft, carrier_rocket, operator, mission_type, outcome, launch_date fields. Both include constructors, getters, setters, and toString() overrides.
Repository Interfaces
src/main/java/com/example/AccountRepository.java, src/main/java/com/example/MoonMissionRepository.java
Defined AccountRepository interface with methods for querying usernames, passwords, accounts by username, listing all accounts, and CRUD operations (create, count, update password, delete). Defined MoonMissionRepository interface with methods for listing missions, querying by id, and counting by year.
Repository Implementations
src/main/java/com/example/AccountRepositoryImpl.java, src/main/java/com/example/MoonMissionRepositoryImpl.java
Implemented JDBC-based data access for Account and MoonMission repositories using DataSource connections, prepared statements, and result mapping. Each method handles connections, query execution, and exception wrapping.
Infrastructure
src/main/java/com/example/SimpleDriverManagerDataSource.java
Implemented DataSource interface wrapping DriverManager with JDBC URL, username, and password; provides getConnection() methods with exception wrapping and no-op implementations for ancillary DataSource methods.
Application Entry Point
src/main/java/com/example/Main.java
Refactored Main class to use DataSource-based initialization, replace direct JDBC calls with repository methods, and introduce interactive login flow with username/password validation, multi-option menu for account and mission operations, and private helper methods for login, CRUD operations, and queries.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Main
    participant AccountRepository
    participant MoonMissionRepository
    participant DataSource
    participant Database as MySQL DB

    User->>Main: Start application
    Main->>DataSource: Create SimpleDriverManagerDataSource
    DataSource->>Database: Store connection parameters

    User->>Main: Enter username/password
    Main->>AccountRepository: findByUsername(username)
    AccountRepository->>DataSource: getConnection()
    DataSource->>Database: DriverManager.getConnection()
    Database-->>DataSource: Connection
    AccountRepository->>Database: Query account by name
    Database-->>AccountRepository: Account record
    AccountRepository-->>Main: Optional<Account>

    alt Login Success
        Main->>User: Show menu
        User->>Main: Select operation (e.g., list missions)
        Main->>MoonMissionRepository: listMoonMissions()
        MoonMissionRepository->>DataSource: getConnection()
        DataSource->>Database: DriverManager.getConnection()
        Database->>MoonMissionRepository: Query all missions
        Database-->>MoonMissionRepository: List<String>
        MoonMissionRepository-->>Main: Display results
        Main-->>User: Show output
    else Login Failure
        Main->>User: Retry or exit
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • JDBC implementation correctness: Verify SQL queries in AccountRepositoryImpl and MoonMissionRepositoryImpl for correctness, parameter binding, and result mapping
  • Exception handling and resource management: Check Connection/PreparedStatement/ResultSet close semantics and exception wrapping patterns across repository classes
  • SQL injection risk: Inspect prepared statement usage and verify all user inputs are parameterized
  • Main.java refactoring: Review the new login loop, menu dispatch logic, and integration with repository objects for correctness and edge cases
  • DataSource implementation: Validate SimpleDriverManagerDataSource's DriverManager wrapping, connection pooling absence, and error handling
  • Type safety: Confirm Optional handling in AccountRepository methods and null-safety across repository implementations

Poem

🐰 A rabbit hops through repos new,
With DataSources and MySQL too,
Where Missions dance and Accounts align,
The interactive flows are oh-so-fine!
From JDBC chains to patterns clean,
The code now blooms—a sight unseen! 🌙✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e629e94 and 93c2937.

📒 Files selected for processing (11)
  • README.md (1 hunks)
  • docker-compose.yml (1 hunks)
  • pom.xml (2 hunks)
  • src/main/java/com/example/Account.java (1 hunks)
  • src/main/java/com/example/AccountRepository.java (1 hunks)
  • src/main/java/com/example/AccountRepositoryImpl.java (1 hunks)
  • src/main/java/com/example/Main.java (2 hunks)
  • src/main/java/com/example/MoonMission.java (1 hunks)
  • src/main/java/com/example/MoonMissionRepository.java (1 hunks)
  • src/main/java/com/example/MoonMissionRepositoryImpl.java (1 hunks)
  • src/main/java/com/example/SimpleDriverManagerDataSource.java (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant